﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
using System.Threading.Tasks;
using Model.WXshopBuiness;
using Xproject.Framework.Core.Repositories;
using Xproject.Framework.Utility.Extensions;

namespace Repository.WXshopBuiness
{
    /// <summary>
    /// 产品详情
    /// </summary>
    public static class ProductContentsRep
    {
        /// <summary>
        /// 得到产品的详情内容
        /// </summary>
        /// <param name="repository"></param>
        /// <param name="productId"></param>
        /// <returns></returns>
        public static List<ProductContents> GetProductContents(this IRepositoryAsync<ProductContents> repository,string productId)
        {
            Expression<Func<ProductContents, bool>> express = i => 1==1;
            if (!string.IsNullOrEmpty(productId))
            {
                express = express.AndAlso(i => i.ProductID.Contains(productId));
            }
            else
            {
                return null;

            }
            return repository.Query().Where(express).Select().OrderBy(i => i.ProductIndex).ToList();
        }
    }
}
